package com.autumn.zero.authorization.configure;

import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

import com.autumn.zero.authorization.application.services.IResourcesModuleAppService;
import com.autumn.zero.authorization.application.services.IResourcesModulePermissionAppService;
import com.autumn.zero.authorization.application.services.impl.ResourcesModuleAppServiceImpl;
import com.autumn.zero.authorization.application.services.impl.ResourcesModulePermissionAppServiceImpl;
import com.autumn.zero.authorization.services.IResourcesService;
import com.autumn.zero.authorization.services.impl.ResourcesServiceImpl;

/**
 * 基本授权配置
 * 
 * @author 老码农 2018-12-08 22:46:19
 */
@Configuration
public class AutumnBaseZeroAuthorizationConfiguration {

	/**
	 * 资源服务
	 * 
	 * @return
	 */
	@Bean
	@Primary
	@ConditionalOnMissingBean(IResourcesService.class)
	public IResourcesService autumnZeroResourcesService() {
		return new ResourcesServiceImpl();
	}

	/**
	 * 资源模块应用服务
	 * 
	 * @return
	 */
	@Bean
	@Primary
	@ConditionalOnMissingBean(IResourcesModuleAppService.class)
	public IResourcesModuleAppService autumnZeroResourcesModuleAppService() {
		return new ResourcesModuleAppServiceImpl();
	}

	/**
	 * 资源权限应用服务
	 * 
	 * @return
	 */
	@Bean
	@Primary
	@ConditionalOnMissingBean(IResourcesModulePermissionAppService.class)
	public IResourcesModulePermissionAppService autumnZeroResourcesPermissionModuleAppService() {
		return new ResourcesModulePermissionAppServiceImpl();
	}
}
